package com.xiao.seckil.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xiao.seckil.entity.SeckillActivityEntity;
import com.xiao.seckil.service.SeckillActivityService;
import com.xiao.group.common.utils.PageUtils;
import com.xiao.group.common.utils.R;



/**
 * 秒杀的一个订单表
 *
 * @author 韩国涛
 * @email 2845009006@gmail.com
 * @date 2021-09-29 09:12:32
 */
@RestController
@RequestMapping("seckil/seckillactivity")
public class SeckillActivityController {
    @Autowired
    private SeckillActivityService seckillActivityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = seckillActivityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{seckilOrder}")
    public R info(@PathVariable("seckilOrder") Integer seckilOrder){
		SeckillActivityEntity seckillActivity = seckillActivityService.getById(seckilOrder);

        return R.ok().put("seckillActivity", seckillActivity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SeckillActivityEntity seckillActivity){
		seckillActivityService.save(seckillActivity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SeckillActivityEntity seckillActivity){
		seckillActivityService.updateById(seckillActivity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] seckilOrders){
		seckillActivityService.removeByIds(Arrays.asList(seckilOrders));

        return R.ok();
    }

}
